<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <button id="_stop">停下切换</button>
    <button id="go">继续切换</button>
    <script>
        // 1.定时器随机body背景颜色.html
        function randomColor(){
            var str = '#'
            for(var i = 0 ; i < 6;i++){
            var num = parseInt(Math.random() * 17).toString(16)
                if(num === '10'){
                    num = parseInt(Math.random() * 10)
                    str += num
                }else{
                    str += num
                }
            }
            return str
        }
        
        
        document.body.style.background =  randomColor() 

       var timer = setInterval(function(){
        document.body.style.background =  randomColor() 
       },1000)

       var timer1 =null
       go.onclick = function(){
            timer1 = setInterval(function(){
                document.body.style.background =  randomColor() 
            },1000)
       }
       
       _stop.onclick = function(){
           clearInterval(timer)
           clearInterval(timer1)
       }
      
       
    </script>
</body>
</html>